# -*- coding: UTF-8 -*-

class Movable(object):
    def __init__(self, pos = (0, 0), direction = (0,0), delta_dx = 0):
        self.x,self.y = pos
        self.direction = direction
        self.delta_dx = delta_dx

    def move(self, time_passed = 0):
        dx, dy = self.direction
        self.x += dx * time_passed
        self.y += dy * time_passed
        # Normalize speed - everything loses inertia over time
        if dx < 0:
            dx += self.delta_dx
        if dx > 0:
            dx -= self.delta_dx
        if dy < 0:
            dy += self.delta_dx
        if dy > 0:
            dy -= self.delta_dx
        if abs(dx) <= self.delta_dx:
            dx = 0
        if abs(dy) <= self.delta_dx:
            dy = 0
        self.direction = (dx,dy)
